package com.eselect.mq.consumer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

/**
 * 死信交换机处理
 */
@Component
@Slf4j
public class DlxConsumer {

    public static final String DLX_EXCHANGE = "dlx.direct.exchange";
    public static final String DLX_ROUTING_KEY = "dlx.direct.key";


    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "dlx.direct.queue1", durable = "true", arguments = @Argument(name = "x-queue-mode", value = "lazy")),
            exchange = @Exchange(value = DLX_EXCHANGE, type = ExchangeTypes.DIRECT),
            key = "dlx.direct.key"
    ))
    public void dlxDirectConsumerQueue1(Message message){
        String msg = new String(message.getBody());
        log.debug("dlxDirectConsumerQueue1 死信队列 接收到消息：{}",  msg);
    }
}
